/**
 * 
 */
package spitfire.ksim.network;


/**
 * <p>
 * KPacket represents the network layer packet in {@link KNetwork}.
 * It has an ID, a source address, a destination address and a pay load for 
 * application specific data. 
 * {@link KNetwork} uses source address and destination address to identify the 
 * hosts and determine if the transmission can be made.
 * </p>
 * 
 * @author Adam
 */
public class KPacket {

	private static long nextId = 0;
	
	private final long packetId = nextId++;
	private final KNetAddress srcAddr;
	private final KNetAddress dstAddr;
	private Object payload;
	
	public KPacket(KNetAddress source, KNetAddress destination, Object payload) {
		srcAddr = source;
		dstAddr = destination;
		this.payload = payload; 
	}
	
	public long getPacketId() {
		return packetId;
	}
	
	public static void resetID() {
		nextId = 0;
	}

	public KNetAddress getSrcAddr() {
		return srcAddr;
	}

	public KNetAddress getDstAddr() {
		return dstAddr;
	}

	public void setPayload(Object payload) {
		this.payload = payload;
	}

	public Object getPayload() {
		return payload;
	}
	
}
